import { invoke } from '@tauri-apps/api/tauri';
import { message } from 'antd';

export default function request(cmd, data) {
    return invoke('command', { action: cmd, json: JSON.stringify(data) })
        .then(x => {
            if (x.success) x.data = x.data ? JSON.parse(x.data) : '';
            else message.error(x.message);

            return x;
        });
}